package com.smart.campus.school.service.impl;

import java.util.List;

import com.smart.campus.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.smart.campus.school.mapper.GradeMapper;
import com.smart.campus.school.domain.Grade;
import com.smart.campus.school.service.IGradeService;
import com.smart.campus.common.core.text.Convert;

/**
 * 年级Service业务层处理
 * 
 * @author Zhihe.Li
 * @date 2020-05-18
 */
@Service
public class GradeServiceImpl implements IGradeService 
{
    @Autowired
    private GradeMapper gradeMapper;

    /**
     * 查询年级
     * 
     * @param id 年级ID
     * @return 年级
     */
    @Override
    public Grade selectGradeById(Long id)
    {
        return gradeMapper.selectGradeById(id);
    }

    /**
     * 查询年级列表
     * 
     * @param grade 年级
     * @return 年级
     */
    @Override
    public List<Grade> selectGradeList(Grade grade)
    {
        return gradeMapper.selectGradeList(grade);
    }

    /**
     * 新增年级
     * 
     * @param grade 年级
     * @return 结果
     */
    @Override
    public int insertGrade(Grade grade)
    {
        grade.setCreateTime(DateUtils.getYear());
        return gradeMapper.insertGrade(grade);
    }

    /**
     * 修改年级
     * 
     * @param grade 年级
     * @return 结果
     */
    @Override
    public int updateGrade(Grade grade)
    {
        grade.setCreateTime(DateUtils.getYear());
        return gradeMapper.updateGrade(grade);
    }

    /**
     * 删除年级对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteGradeByIds(String ids)
    {
        return gradeMapper.deleteGradeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除年级信息
     * 
     * @param id 年级ID
     * @return 结果
     */
    @Override
    public int deleteGradeById(Long id)
    {
        return gradeMapper.deleteGradeById(id);
    }
}
